package com.rongji.cms.tools.common.exception;

import com.rongji.cms.tools.common.enums.CommonResultCode;
import com.rongji.cms.tools.common.vo.ResultVO;
import org.springframework.boot.web.servlet.error.ErrorController;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 *
 *
 * @return
 * @author yang
 * @create 2022/6/6
 * 404要这样单独处理
 * 参考链接 https://juejin.cn/post/6844904193182941192
**/
@RestController
public class NotFoundException implements ErrorController {

    private static final String ERROR_PATH = "/error";

    @RequestMapping(ERROR_PATH)
    public ResultVO error() {
        // 4、接口不存在
        return  ResultVO.fail(CommonResultCode.NOT_FOUND.getCode(), CommonResultCode.NOT_FOUND.getMsg());
    }



    public String getErrorPath() {
        return ERROR_PATH;
    }
}

